// a quick trick to save & restore the focus between ajax updates of the datatable 

var focusElementId = null

function saveFocus() {
    
    var elementId = $('*:focus').attr("id") ;
    
    if ( elementId != null )  
        focusElementId = elementId ;        
}

function restoreFocus() {
    
    if ( focusElementId != null ) {
        var elem  = PrimeFaces.escapeClientId(focusElementId) ;
        var tmp = $(elem).val();
        $(elem).focus();
        $(elem).val( tmp );
    }
}